package kr.hkit.powerjava.chapter06;

import java.util.Scanner;

public class Lab {
	public static void main(String[] args) {
		double divisor = 1.0d;
		double divident = 4.0d;
		double sum = 0.0d;
		int loop_count;
		
		Scanner input = new Scanner(System.in);
		System.out.print("반복횟수:");
		loop_count = input.nextInt();
		
		while(loop_count > 0){
			sum = sum + divident / divisor;
			divident = -1.0 * divident;
			divisor = divisor + 2;
			loop_count--;
		}
		System.out.println("Pi = " + sum);
	}

}
